<?php
/**
 * @author living
 * @desc
 **/
class MobileController extends AppController {
	var $name = 'Mobile';
	var $uses = array (
			'SysParams',
			'Mobile'
			
	);
	function index() {
		$this->initmobile ();
		$area_info = $this->SysParams->getArea();
//  		$tema_info = $this->SysParams->getTema();
 		$tema_info = $this->Mobile->getMobileCategoryList();

		$areaJobs= array();
		//新着求人
		//get $pickup_info
		$areaJobs[] = $this->Mobile->getMobilePickUpJob(3);
		$areaJobs[93] = $this->Mobile->getJobListByAreaId(93,3);
		$areaJobs[94] = $this->Mobile->getJobListByAreaId(94,3);
		$areaJobs[96] = $this->Mobile->getJobListByAreaId(96,3);
		$areaJobs[97] = $this->Mobile->getJobListByAreaId(97,3);

		$this->set('areaJobs', $areaJobs);
		$this->set('area_info', $area_info);
		$this->set('tema_info', $tema_info);
		$this->render ( 'index' );
	}
	function search($data) {
		$tameid = filter_input(INPUT_GET, 'tameid', FILTER_VALIDATE_INT);
		$areaid = filter_input(INPUT_GET, 'areaid', FILTER_VALIDATE_INT);
		$attid = filter_input(INPUT_GET, 'attid', FILTER_VALIDATE_INT);
		$hmid = filter_input(INPUT_GET, 'hmid', FILTER_VALIDATE_INT);
		$page = filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT);
		$page = $page?$page:1;
		$post_data = $this->SysParams->generateList("\"SysParams\".kbn = 'post_id' and \"SysParams\".deleted is null");
		
		$lang_data = $this->SysParams->generateList("\"SysParams\".kbn = 'hope_language_id' and \"SysParams\".deleted is null",'sort');
		
		$memb_type = $this->SysParams->generateList("\"SysParams\".kbn = 'hope_member_id' and \"SysParams\".deleted is null");
		
		$attention_data = $this->SysParams->generateList("\"SysParams\".kbn = 'attention_id' and \"SysParams\".deleted is null");
		
		$temas_tmp=$this->SysParams->generateList("\"SysParams\".kbn = 'tema_id' and \"SysParams\".deleted is null","order by id asc");

		$temas = $this->Mobile->getMobileCategoryList();

		$areas=$this->SysParams->generateList("\"SysParams\".kbn = 'area_id' and \"SysParams\".deleted is null","order by id asc");
		$jobs = $this->Mobile->getJobList($tameid,$areaid,$attid,$hmid,$page,$temas_tmp,$lang_data,$memb_type,$attention_data);
		$quertdata = array('tameid'=>$tameid,'areaid'=>$areaid);
		
		
		$top_title = "";
		if($areaid>0){
			$sid = $areaid;
			$data = $this->SysParams->generateList("\"SysParams\".id = ".$sid." and \"SysParams\".kbn='area_id'");
			$top_title = $data[$sid];
			if($areaid==9397)
				$top_title = '中国全土';
		}
			
		if($tameid>0){
			$data = isset($temas[$tameid])? $temas:"";
			if(!$data)
			{
				$sid = $tameid;
				$data = $this->SysParams->generateList("\"SysParams\".id = ".$tameid." and \"SysParams\".kbn='tema_id'");
			}
			if($top_title)
				$top_title .= " & ".$data[$tameid];
			else
				$top_title = $data[$tameid];
		}
			
		
		$this->pageTitle=$top_title.'-カモメ中国転職：求人検索';
		
		
		$jobs['page'] = $page;
		$this->set('top_title',$top_title);
		$this->set('temas',$temas);
		$this->set('areas',$areas);
		$this->set('jobs',$jobs);
		$this->set('quertdata',$quertdata);
        $this->initmobile ();
		$this->render ( 'joblist' );
	}
	
	function jobdetail($job_id,$url=null) {
		$this->initmobile ();
		$this->render ( 'jobdetail' );
	}

}